﻿using ApiIOCService.Interface;
using Microsoft.Practices.Unity;
using MyWeb.API.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using TestCoupon.Model;

namespace TestApi.Controllers
{
    public class CouponBatchController : ApiController
    {
        [Dependency]
        public ICouponService CouponService { get; set; }

        [System.Web.Http.HttpGet]
        public BaseResponseModel<CouponListsResponse> GetCouponBatchList()
        {
            BaseResponseModel<CouponListsResponse> result = new BaseResponseModel<CouponListsResponse>();
            try
            {
                var list = CouponService.GetCouponBatchs();
                if (list != null && list.Count > 0)
                {
                    CouponListsResponse data = new CouponListsResponse();
                    data.CouponBatchList = list;
                    result = new SuccessResponseModel<CouponListsResponse>(data);
                }
                else
                {
                    result = new BussniessErrorResponseModel<CouponListsResponse>("数据不存在");
                }
            }
            catch (Exception ex)
            {
                result = new SystemErrorResponseModel<CouponListsResponse>(ex.Message);
            }
            return result;
        }
    }
}
